<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">

				<el-form-item label="省份" prop="province">
					<el-select v-model="filters.province" filterable :filter-method="selectfilter" placeholder="请选择省份">
						<el-option value="0" label="全部">全部</el-option>
						<el-option
								v-for="item in info"
								:key="item.provincename"
								:label="item.provincename"
								:value="item.provincename">
						</el-option>
					</el-select>
				</el-form-item>

				<el-form-item label="地市" prop="province">
					<el-select v-model="filters.city" filterable  placeholder="请选择地市">
						<el-option value="0" label="全部">全部</el-option>
						<el-option
								v-for="item in citys"
								:key="item.city"
								:label="item.city"
								:value="item.city">
						</el-option>
					</el-select>
				</el-form-item>

				<el-form-item>
					<el-input v-model="filters.productPrice" placeholder="产品金额"></el-input>
				</el-form-item>

				<el-form-item label="订单状态" prop="state">
					<el-select v-model="filters.status" placeholder="订单状态">
						<el-option value="0" label="全部">全部</el-option>
						<el-option value="2" label="充值成功">充值成功</el-option>
						<el-option value="3" label="充值失败">充值失败</el-option>
					</el-select>
				</el-form-item>

				<el-form-item>
					<el-date-picker type="datetime" placeholder="开始时间"  format="yyyy-MM-dd HH:mm:ss"   v-model="filters.createTime" style="width: 100%;"></el-date-picker>
				</el-form-item>
				<el-form-item>
					<el-date-picker type="datetime" placeholder="结束时间" format="yyyy-MM-dd HH:mm:ss"   v-model="filters.endtime" style="width: 100%;"></el-date-picker>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getSumPrice">查询</el-button>
				</el-form-item>

				<!--<el-form-item>-->
					<!--<el-button type="primary" v-on:click="importBroadband">导入</el-button>-->
				<!--</el-form-item>-->



			</el-form>
		</el-col>
		<!--列表-->
		<template>
			<el-table :data="virtuals" highlight-current-row v-loading="loading" max-height="620"  @selection-change="selsChange" border  style="width: 100%;">
				<el-table-column  type="selection"  width="80" label="编号">
				</el-table-column>
				<el-table-column prop="sumprice" label="总金额" width="170px" show-overflow-tooltip  >
				</el-table-column>


				<!--<el-table-column label="操作"  fixed="right"   width="220">-->
					<!--<template scope="scope"   >-->
						<!--&lt;!&ndash;<el-button size="small"   @click="handleInTime(scope.$index, scope.row)">安装时间&ndash;&gt;-->
						<!--&lt;!&ndash;</el-button>&ndash;&gt;-->
						<!--&lt;!&ndash;<el-button size="small"   @click="handleEndTime(scope.$index, scope.row)">结束时间&ndash;&gt;-->
						<!--&lt;!&ndash;</el-button>&ndash;&gt;-->
						<!--<el-button size="small"   @click="handleEdit(scope.$index, scope.row)">-->
						<!--编辑-->
						<!--</el-button>-->
					<!--</template>-->
				<!--</el-table-column>-->
			</el-table>
		</template>
		<el-pagination
				@current-change="handleCurrentChange"
				@size-change="handleSizeChange"
				layout="total,sizes,prev, pager, next"
				:total="total">
		</el-pagination>
	</section>

</template>
<script>
	import { getSumPrice ,findAllPro,findProvinceCity} from '../../api/api';
	//import NProgress from 'nprogress'
    import moment from 'moment';
    var crypto = require('crypto');
	export default {
		data() {
			return {
				filters: {
                    createTime:  moment(new Date(),"YYYY-MM-DD HH:mm:ss").format('YYYY-MM-DD') + " 00:00:00",
                    endtime:'',
                    province:'',
                    productPrice:'',
                    status:'',
                    dowonphonenum:'',
                    city:''

				},
                fileList: [],
                isShowSupper:JSON.parse(sessionStorage.getItem("user")).usertype === 2 ? true : false,
				start:0,
				pageSize:10,
                total:0,
				loading: false,
				users: [],
                info:[],
                citys:[],
                virtuals:[],
                sels:[],

			}
		},
		methods: {
            getSumPrice: function () {
				let para = {

                    createTime:  moment(this.filters.createTime,"YYYY-MM-DD HH:mm:ss").format('YYYY-MM-DD HH:mm:ss'),
                    endtime:this.filters.endtime == "" ? "" :  moment(this.filters.endtime,"YYYY-MM-DD HH:mm:ss").format('YYYY-MM-DD HH:mm:ss'),
                    province: this.filters.province == "0" ? "" :this.filters.province,
                    status:this.filters.status == "0" ? "" : this.filters.status,
                    productPrice:this.filters.productPrice,
                    city : this.filters.province == "0" ? "" : this.filters.city == "0" ? "" : this.filters.city
				};
				this.loading = true;
                getSumPrice(para).then(datas => {
                    this.loading = false;
                    let { message, code, data } = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else {
                        this.virtuals = [];
						var obj = new Object();
                        obj.sumprice = data;
                        this.virtuals.push(obj);
                    }
                }).catch(e =>{

				});
			},handleCurrentChange:function(val){
                this.start = val - 1;
                this.getSumPrice();
			},
            handleSizeChange:function(val){
			    this.pageSize = val;
			    this.getSumPrice();
			},selsChange: function (sels) {
                this.sels = sels;
            } ,
            findAllPro:function(){
                let para = {useruuid: ''};
                findAllPro(para).then(datas => {
                    let {message, code, data} = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else {
                        this.info = data;
                    }
                });
            },
            selectfilter:function(row){
                if(row != ""){
                    this.findProvinceCity(row)
                }
            },findProvinceCity:function (province) {
                let para = {
                    province : province
                };
                findProvinceCity(para).then((datas) => {
                    let { message, code, data } = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    }
                    this.citys = data;
                });
            }
		},

		mounted() {
		    this.findAllPro();
			this.getSumPrice();
		},
    	beforeCreate: function (){
//            window.location.reload();
		}
	};

</script>

<style scoped>

</style>
